<template>
  <div>
    <my-header></my-header>
    <div class="info">
      <el-form :model="attraction" status-icon inline label-width="100px">
        <el-form-item label="名称" prop="name">
          <el-input v-model="attraction.name" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="地点" prop="location">
          <el-input v-model="attraction.location" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="评论" prop="comment">
          <el-input v-model="attraction.comment" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="关键字" prop="keyword">
          <el-input v-model="attraction.keyword" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="图片" prop="picture">
          <el-input v-model="attraction.picture" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="主题" prop="theme">
          <el-input v-model="attraction.theme" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="开放时间" prop="open">
          <el-date-picker v-model="attraction.open" type="datetime" placeholder="选择开放时间"></el-date-picker>
        </el-form-item>
        <el-form-item label="关闭时间" prop="close">
          <el-date-picker v-model="attraction.close" type="datetime" placeholder="选择关闭时间"></el-date-picker>
        </el-form-item>
        <el-form-item label="成人票" prop="adult">
          <el-input v-model="attraction.adult" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="学生票" prop="student">
          <el-input v-model="attraction.student" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="儿童票" prop="children">
          <el-input v-model="attraction.children" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="评分" prop="score">
          <el-input v-model="attraction.score" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="addAttraction">发布</el-button>
          <el-button type="primary" @click="goBack">返回</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>

</template>

<script>
import { reqAddAttraction } from "@/api/index";
import MyHeader from "@/components/MyHeader.vue";

export default {
  components: { MyHeader },
  name: "UserInfo",
  methods: {
    addAttraction() {
      reqAddAttraction(this.attraction).then((res) => {
        if (res.code == 200) {
          alert("添加景点信息成功");
          this.$router.back();
        }
      });
    },
    goBack() {
      this.$router.back();
    },
  },
  data() {
    return {
      attraction: {
        name: "景点",
        location: "location",
        comment: "comment",
        keyword: "keyword",
        picture: "picture",
        theme: "",
        open: "",
        close: "",
        adult: "",
        student: "",
        children: "",
        score: "",
      },
    };
  },
};
</script>

<style scoped>
.info {
  margin-top: 100px;
  margin-bottom: 00px;
  margin-left: 340px;
  /* margin: 20%;  */
  /* height: 600px; */
  width: 700px;
  text-align: center;
}
.el-input {
  width: 220px;
}
</style>